package com.Gehaltsrechner;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


public class Datenbank extends SQLiteOpenHelper
{
	public static final String DATENBANK_DATEI_NAME = "dbase.db";
	public static final String DATENBANK_NAME = "Rechner";
	public static int DATENBANK_VERSION = 1;
		
	private static final String create = "CREATE TABLE Rechner (" 
			+ "Wert TNTEGER PRIMARY KEY," 
			+ "Inhalt TEXT NOT NULL);";
	
	
	public Datenbank (Context context)
	{
		super (context,
				DATENBANK_DATEI_NAME,
				null,
				DATENBANK_VERSION);
	}

	public void onCreate(SQLiteDatabase db)
	{
		db.execSQL (create);
		
		//Stundenlohn
		ContentValues werte = new ContentValues ();
  	werte.put ("Wert", 1);
  	werte.put ("Inhalt", "0");
  	db.insert ("Rechner", null, werte);
  	
  	//Sprache
  	werte = new ContentValues ();
  	werte.put ("Wert", 2);
  	werte.put ("Inhalt", Lokal.english.toString ());
  	db.insert ("Rechner", null, werte);
  	
  	//Gesamtverdient
  	werte = new ContentValues ();
  	werte.put ("Wert", 3);
  	werte.put ("Inhalt", "0");
  	db.insert ("Rechner", null, werte);
  	
  	//Pausenzeit
  	werte = new ContentValues ();
  	werte.put ("Wert", 4);
  	werte.put ("Inhalt", "0");
  	db.insert ("Rechner", null, werte);
	}


	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
	{
		db.execSQL ("DROP TABLE IF EXISTS " + DATENBANK_NAME + ";");
		onCreate(db);
		DATENBANK_VERSION = 1;
	}
}
